package com.crm.utils;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class BaseAction<T> extends ActionSupport implements ModelDriven<T> {
	private Class actualType;
	private T model;
	{
		Type genericSuperclass = this.getClass().getGenericSuperclass();
		ParameterizedType pType =  (ParameterizedType) genericSuperclass;
		Type[] actualTypeArguments = pType.getActualTypeArguments();
		actualType = (Class) actualTypeArguments[0];
		try {
			model=(T) actualType.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
	}
	public T getModel() {
		return model;
	}

}
